package com.jiazhong.boot.example.emp.mapper;

import com.jiazhong.boot.commons.bean.Emp;
import org.apache.ibatis.annotations.*;

import java.util.List;

@Mapper
public interface EmpMapper {

    List<Emp> findAll();

    @Select("select distinct job from emp")
    List<String> findAllJob();

    @Select("select empno,ename from emp where state=1")
    List<Emp> findAllMgr();

    @Select("select count(0) from emp where ename=#{ename}")
    int findEnameCount(String ename);

    @Insert("insert into emp values(null,#{ename},#{job},#{mgr},now(),#{sal},#{comm},#{deptNo},1) ")
    int save(Emp emp);

    @Delete("update emp set state=0 where empno=#{id} and state=1")
    int removeById(int id);

    int removeByBatch(List<String> list);

    @Update("update emp set ename=#{ename},job=#{job},mgr=#{mgr},sal=#{sal},comm=#{comm} where empno = #{empNo} and state=1")
    int update(Emp emp);

    List<Emp> findCascade(Emp emp);
}
